<?php
use yii\bootstrap\ActiveForm;
use yii\helpers\Html;
use yii\helpers\Url;

?>
<div class="row">
    <div class="container lh30">
        <a class="topNav" href="<?=Url::toRoute('/system/site/index')?>" style=""><img src="<?=Yii::getAlias('@web/backend/img/home/home.png');?>" alt="首页"/>返回首页</a>
    </div>
</div>

<div class="row nav-brand-bg borB">
    <div class="container lh30">
        <ul class="nav nav-tabs">
            <li><a href="<?=Url::toRoute(['repertory/repertorymanage']) ?>" style="">库存管理</a></li>
            <li><a href="<?=Url::toRoute(['repertoryinc/storage','type' => 1]) ?>" style="">商品入库</a></li>
            <li class="active"><a href="<?=Url::toRoute(['goodsdec/repertoryout']) ?>">商品出库</a></li>
            <li><a href="<?=Url::toRoute(['repertoryinc/increcord']) ?>">入库流水</a></li>
            <li><a href="<?=Url::toRoute(['goodsdec/decrecord']) ?>">出库流水</a></li>
        </ul>
    </div>
</div>

<div class="tab-content">
    <div id="income" class="row tab-pane in active fade">
        <div class="container">
            <div class="mg20-y lh45 clearfix">
                <a class="btnBg text-center lh45 repertory_list" title="选择商品" dhref="<?=Url::toRoute(['repertory/list','type' => -2]) ?>" href="javascript:void(0)"><img src="<?=Yii::getAlias('@web/backend/img/stocks/add_shop.png');?>"/>选择商品</a>
                <span style="padding: 10px;">扫码枪出库</span>
                <div style="position: relative;display: inline-block;">
                    <input type="text" placeholder="" class="code" style="width: 303px;height: 45px;"/>
                    <img style="position: absolute;right: 10px;top:50%;margin-top: -10px;" src="<?=Yii::getAlias('@web/backend/img/reportryinc/scan_ico.png');?>" alt=""/>
                </div>
            </div>
        <?php if(empty($repertory)){?>
            <table class="table table-bordered mt20" style="table-layout: fixed;">
                <thead>
                <tr>
                    <th>商品名称</th>
                    <th>规格</th>
                    <th>库存</th>
                    <!-- 店长 -->
                    <?php if($this->userinfo->user_type == 4){?>
                        <th>零售价</th>
                    <?php }?>
                    <th>出库数量</th>
                    <th>供应商</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td <?php if($this->userinfo->user_type == 4){?>colspan="7"<?php }else{?>colspan="6"<?php }?>  align="center"><img src="<?=Yii::getAlias('@web/backend/img/nodata.gif');?>"></td>
                </tr>
                </tbody>
            </table>
        <?php }else{?>
            <?php ActiveForm::begin(['id'=>'myform'])?>
            <table class="table table-bordered mt20">
                <thead>
                <tr>
                    <th>商品名称</th>
                    <th>规格</th>
                    <th>库存</th>
                    <!-- 店长 -->
					<?php if($this->userinfo->user_type == 4){?>
					<th>零售价</th>
					<?php }?>
                    <th>出库数量</th>
                    <th>供应商</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <?php foreach ($repertory as $r){?>
                <tr>
                    <input id="rid" type="hidden" name="repertory_id[]" value="<?=Html::encode($r['repertory_id']) ?>" readonly/>
                    <input type="hidden" name="goods_sell_price[]" value="<?=Html::encode($r['goods_sell_price']) ?>" readonly/>
                    <td><input type="text" name="goods_name[]" value="<?=Html::encode($r['repertory_name']) ?>" readonly/></td>
                    <td><input type="text" name="goods_specs[]" value="<?=Html::encode($r['repertory_specs']) ?>" readonly/></td>
                    <td><input type="text" name="repertory_count[]" value="<?=Html::encode($r['repertory_count']) ?>" readonly/></td>
                    <?php if($this->userinfo->user_type == 4){?>
                       <td><input  type="text" name="" value="<?=Html::encode($r['goods_sell_price']) ?>" readonly/></td>
                    <?php }?>
                    <td><input class="dec_num" type="text" name="dec_count[]" value="<?php if(isset($r[0])){?><?=Html::encode($r[0]) ?><?php }?>"/></td>
                    <td><input type="text" name="supplier_name[]" value="<?=Html::encode($r['supplier_name']) ?>" readonly/></td>
                    <td><a href="<?=Url::toRoute(['repertory/delselect','id' => $r['repertory_id'],'type' => 2]) ?>" class="del btn btn-sm btn-borB">删除</a></td>
                </tr>
                <?php }?>
                <tr class="tips" style="border:none ">
                    <td class="text-center" <?php if($this->userinfo->user_type == 4){?>colspan="7"<?php }else{?>colspan="6"<?php }?>>
                        共计数量：
                        <em class="red" id="red">0件</em>
                    </td>
                </tr>
                </tbody>
            </table>

            <div class="mt20">
                <label>出库类型</label>
                <div class="select">
                    <select class="" name="dec_type">
                        <option value="1">其他</option>
                        <option value="2">报废/破损/过期</option>
                        <option value="3">赠送</option>
                        <option value="4">调拨</option>
                        <option value="5">售卖</option>
                        <option value="6">使用</option>
                    </select>
                </div>
            </div>
            <div class="clearfix mt20">
                <label class="pull-left mr10">备注</label>
                <div class="pull-left">
                    <textarea name="dec_remark" style="vertical-align: text-top; resize: none; width: 1365px; max-width: 1365px; height: 180px; max-height: 180px; padding: 10px;"></textarea>
                    <button type="submit" class="btnBg mt20" style="display: block; border: none; margin: 0 auto">提交</button>
                    <!--  <a class="btnBg mt20" href="" style="display: block;">提交</a>  -->
                </div>
            </div>
            <?php ActiveForm::end();?>
        <?php }?>
        </div>
    </div>
</div>

<?php $this->registerJsFile("@web/system/goodsdec/repertoryout.js",['position'=>$this::POS_END]);?>
